<?php
class Content extends MY_Controller{
    public function __construct() {
        parent::__construct();
        $this->load->model('model_content');
    }
    public function index() {
		$data['act'] = 0;
		$data['title'] = "Before you go";
		$data['result'] = $this->model_content->getdataone(1);
		$listcate = $this->model_content->listcate();
		$articles = array();
		foreach($listcate as $key => $items){
			$articles[] = $this->model_content->getarticels($items['category_id']);
		}
		$data['listall'] = array("listcate" => $listcate,"articles" => $articles);
		//$this->debug($data['listall']);
        $this->load->view('content/layout',$data);
    }
    public function detail(){
		$data['act'] = 0;
		$id = $this->uri->segment(2);
		$data['result'] = $this->model_content->getdata($id);
		$listcate = $this->model_content->listcate();
		$articles = array();
		foreach($listcate as $key => $items){
			$articles[] = $this->model_content->getarticels($items['category_id']);
		}
		$data['listall'] = array("listcate" => $listcate,"articles" => $articles);
		if($data['result'] == NULL){
			redirect(base_url());
		}
		$data['title'] = $data['result']['con_title']." - before you go";
		//$this->debug($data['result']);
        $this->load->view('content/detail/layout',$data);
    }
}
?>